﻿using System.Collections;
using System.Collections.Generic;
using GameFramework.Battle.Core;
using Gameplay.PVE.Entity;
using UnityEngine;

namespace Gameplay.PVE
{
    public class SearchTarget : Havior
    {
        private BattleUnit unit;
        public override ETaskResult Execute(ETaskResult result,bool last)
        {
            //Debug.LogError("search");
            unit.Transmit(ETransmitType.AutoSearch);
            if (unit.Data.lockTarget != null)
            {
                return ETaskResult.Successed;
            }
            else if (PveManager.Instance.isInRpg)
            {
                unit.Data.SetTargetPosition(unit.Data.position);
            }
            return ETaskResult.Running;
        }

        public override void Parse(Dictionary<string, object> data)
        {
           
        }

        public override void SharedVariableChanged(string key, object value)
        {
            if (key == ESharedVariablesType.Executor)
            {
                unit = (BattleUnit) value;
            }
        }
    }

}
